package com.kfm.mybatis.mapper;

import com.kfm.mybatis.model.Userinfo;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IUserinfoMapper {

    @Select("select * from userinfo")
    // @Results == <resultMap>
    @Results(id = "result", value = {
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "username", column = "username"),
            @Result(property = "password", column = "password"),
            @Result(property = "name", column = "name"),
            @Result(property = "gender", column = "gender"),
            @Result(property = "birthday", column = "birthday"),
            @Result(property = "phone", column = "phone"),
            @Result(property = "email", column = "email"),
            @Result(property = "qq", column = "qq"),
            @Result(property = "img", column = "img"),
            @Result(property = "createDate", column = "create_date"),
            @Result(property = "updateDate", column = "update_date"),
            @Result(property = "state", column = "state"),
            @Result(property = "del", column = "is_del")
    })
    List<Userinfo> selectAll();

    @Select("select * from userinfo where id = #{id}")
    // 引用 @Results 的 id
    @ResultMap("result")
    Userinfo selectById(String id);
}
